package com.wm.android.mydemos;

import java.util.ArrayList;

import com.wm.android.mydemos.componnent.MyListView;
import com.wm.android.mydemos.tools.ListUtility;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.app.Activity;

public class CustomListViewActivity extends Activity {
	
	ArrayList<String> mDataList = ListUtility.SIMPLE_LIST;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_custom_list_view);
		
		MyListView mListView = (MyListView) findViewById(R.id.listview);
		mListView.setAdapter(new MyDemosListView_Adapter());
	}
	
	public class MyDemosListView_Adapter extends BaseAdapter{

		@Override
		public int getCount() {
			
			return mDataList.size();
		}

		@Override
		public Object getItem(int position) {
			
			return null;
		}

		@Override
		public long getItemId(int position) {
			
			return 0;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			
			if(convertView == null){
				convertView = getLayoutInflater().inflate(R.layout.simpleitem1, null);
			}
			
			TextView mTextView = (TextView) convertView.findViewById(R.id.title);
			mTextView.setText(mDataList.get(position));
			
			return convertView;
		}
	}
}
